<template>
	<view class="tab-bar">
		<view class="tab-item" v-for="(item,index) in data" :key="index" :class="{active: current == index}" @tap='goPage(index)'>
			<view>
				<image :src="item.iconPath" v-if="current != index" mode="" class="imgIcon" :class="{big:item.big}"></image>
				<image :src="item.selectedIconPath" v-if="current == index" mode="" :class="{big:item.big}" class="imgIcon"></image>
			</view>
			<view class="text" v-if="item.text"  :style="{color:( index == current ? item.color:'#8e8c8c')}">{{item.text}}</view>
		</view>
	</view>
</template>
<script>
	export default {
		name:"tab-bar",
		props:['current'],
		data() {
			return {
				data:[
					{
						iconPath: '../../static/img/tab1-active.png',
						selectedIconPath: '../../static/img/tab1.png',
						pagePath: '/pages/index/index',
						text: '首页',
						
					},
					{
						iconPath: '../../static/img/tab2.png',
						selectedIconPath: '../../static/img/tab2.png',
						pagePath: '',
						text: '惠民券',
						
					},
					{
						iconPath: '../../static/img/tab3.png',
						selectedIconPath: '../../static/img/tab3.png',
						pagePath: '',
						text: '云逛展',	
					}
				]
			};
		},
		created() {
			// if(this.$route.query.type == "top" ) {
			// 	this.getIS_upTop()
			// } else {
			// 	
			// }
			// this.getIS_up()
			// console.log(this.is_up);
			// console.log(this.is_up);
		},
		
		methods:{
			showShare() {
				this.showShareEvent();
			},
			showShareEvent() {
				this.$refs.showS.show();
			},
			goPage(index) {
				if ( index == 1 ) {
					wx.navigateToMiniProgram({
					    appId: 'wx647fbc272d20c1e2',
					    path: '/bundle/pages/get_coupon/get_coupon',//要打开B小程序的页面
					    extraData: { },//需要传递给目标小程序的数据，目标小程序可在 App.onLaunch，App.onShow 中获取到这份数据
					    envVersion: 'release',//打开的对应小程序环境：开发develop、体验trial、生产release 
					    success(res) {
					        console.log('打开成功',res)
					    }
					}) 
				}
				if ( index == 2 ) {
					wx.navigateToMiniProgram({
					    appId: 'wx647fbc272d20c1e2',
					    path: '/pages/index/index',//要打开B小程序的页面
					    extraData: { },//需要传递给目标小程序的数据，目标小程序可在 App.onLaunch，App.onShow 中获取到这份数据
					    envVersion: 'release',//打开的对应小程序环境：开发develop、体验trial、生产release 
					    success(res) {
					        console.log('打开成功',res)
					    }
					}) 
				}
			},
			async  goUpLoad() {
				var id = this.$route.query.id;
				const res = await this.$http({
					  url:'activity/check/'  + id,
					  method:'get',
					  data:{}
				 })
				// console.log(id);
				//console.log(res);
				if(res.is_exist_teacher_article) {
					uni.showToast({
						title:'您已上传过作品了!',
						icon:"none"
					})
				} else {
					uni.navigateTo({
					    url:'/pages/upLoad/upLoad?id=' + id 
				    })
				}
				
			}
		}
	}
	
</script>
<style lang="scss">
	.tab-bar {
		position: fixed;
		width: 100vw;
		// height: 100rpx;
		padding-top: 20rpx;
		bottom: -2rpx;
		background-color: #fff;
		z-index: 99999;
		display: flex;
		padding-bottom: 48rpx;
		box-shadow: 1px -2px 6px rgba(0,0,0,0.1);
		.tab-item {
			flex:1;
			text-align: center;
		}
		.imgIcon {
			width: 60rpx;
			height: 60rpx;
			&.big {
				width: 96rpx;
				height: 90rpx;
			}
		}
		.text {
			color:#8e8c8c;
			font-size: 20rpx;
		}
	}
</style>